'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  // 首页报表
  router.get('/api/dashboard', controller.home.dashboard);
  // 上传
  router.post('/api/upload/file', controller.uploadcos.file);
  // 登录
  router.post('/api/user/login', controller.user.login);
  router.post('/api/user/apply', controller.user.apply);
  router.post('/api/user/updatePassword', controller.user.updatePassword);
  // banner
  router.get('/api/banner/list', controller.banner.allList);
  router.resources('banner', '/api/banner', controller.banner);
  router.resources('gallery', '/api/gallery', controller.gallery);
    // ship
    router.get('/api/ship/detailByCode', controller.ship.detailByCode);
    router.get('/api/ship/list', controller.ship.allList);
    router.resources('ship', '/api/ship', controller.ship);

    // API Logs
    router.resources('apiLog', '/api/apiLog', controller.apiLog);

    // order sendEmail

    router.post('/api/order/sendEmail', controller.order.sendEmail);
    router.post('/api/order/cancel', controller.order.cancel);
    router.post('/api/order/refund', controller.order.refund);
    router.get('/api/order/list', controller.order.allList);
    router.resources('order', '/api/order', controller.order);
    // cycle
    router.get('/api/cycle/list', controller.cycle.allList);
    router.post('/api/cycle/batchCreate', controller.cycle.batchCreate);
    router.post('/api/cycle/createCustom', controller.cycle.createCustom);

    router.resources('cycle', '/api/cycle', controller.cycle);
    // coupon
    router.get('/api/coupon/list', controller.coupon.allList);
    router.resources('coupon', '/api/coupon', controller.coupon);
    // user
    router.get('/api/user/list', controller.user.allList);
    router.resources('user', '/api/user', controller.user);
    // 发票
    router.post('/api/invoice/amount', controller.invoice.getAmount);
    router.resources('invoice', '/api/invoice', controller.invoice);
    // paypal 支付相关
    router.post('/api/payment/paypal/create', controller.paypal.createPayPalOrder);
    router.post('/api/payment/paypal/verify', controller.paypal.verifyPayment);
    router.post('/api/payment/paypal/refund', controller.paypal.refundPayment);
    // 阿里支付
    router.post('/api/payment/alipay/create', controller.alipay.createAlipayOrder);
    router.post('/api/payment/alipay/notify', controller.alipay.notify);
    router.post('/api/payment/alipay/refund', controller.alipay.refund);
    router.resources('contact', '/api/contact', controller.contact);
    // 邮件模版
  router.resources('email', '/api/email', controller.email);
  router.resources('emailTemplate', '/api/emailTemplate', controller.emailTemplate);
};
